package com.ycc.springcloud.config;


import org.springframework.context.annotation.Configuration;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */

@Configuration
public class AlipayConfig {

    //↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2021000116692403";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOgQx57DOxTMFJixJUlt1F69BS4zYdAK6Fgy+nqP70ek/0QbOuNTs9jSlEyufuhszSfgHpMvmV14sFRqldLhaBOboT1u5grLKCQz44zie0lKw9lSBuU3PNOtjiU5iy3a21NktYMXxa4I4QsNm12rdBgGJxMN4p4Z6EYQu1n8HjGahJQDzh6yet7/j+IBIKZl8UvKz6yiD3zRnm96+Izmi57WIzCeEwIIyFvN1LbV/T2C5DYZfAzXB4jO2HZCLwNqgwbjlYXQk5clFlxTkLyh/7qlgup8C4KTxmotlppl5vjPTQ1FWY8WPxkI/3lLPA7eHJfTV2wLYVGyXOeUYktTCRAgMBAAECggEACMqJo28gzD1+RQk8oIlDpkRhvAWcOiPbSifJkZOqNvI2ESny4km12er2hM02jnsCoTtoDWt0IKLqcjEN6L+biajReSK/RzJS7yS5s2VjX1as9nowxUGcPnJw5UG10HeLe5lyH7ELoDrLEX7V5d4HyywSBMuVyaanPu96tiK0+Fv9r+szDxc/xkwZPo7rWYLRm8Ja0iNtTLvyjrvGFhfwcEG4kRlHkd4KaYlR1mP5PCcv3zESYbakXTtDunBfdF4M5DBraWacIYCQeMEk6tjlIz/i7tItRY8L54g02+dnoVVJCf6ggbVO3NeqgWxVnu6EK4YO2r/Thu6xxsd2p723gQKBgQDpQ764Z6O/T+jQ4+1sFbYtZJhxS5prdtxIWIQBkArKg4owZ21Qbebdr4bJqdS5FTXXHugZqHPcQv0ClXHHMNNypMZ3+W0HtKa51OXNGozY9iYWpCrQUf3Grjx/UMI7W+1v2nUN+fbh7g+dy+IY/wK9Ml/beYaCuUGdCug17uhcWQKBgQDioZf/9HhTfQ2fJEao2j87LXvmH0ovtU+Td3t+0jliXo/lYQFApFk4sYiIATlCWgfSD6atAJU2oSJ0ykx5CqxQrvPzHoXLjkYuSs5ilYATzutfknX1Atw7T2ujTwDOxtS0MPF+RujWmWKK78umYtiwyksx6MuEZtcVYgH5tgqO+QKBgHWfopFsOWbkDZsgA/3HqPiUzEX9AJ4F7qhQcigzkS1zTQCBdt7ivFK3CvmvuMOnjWGvhQxDJEFCSkC+SQRPe6BItIeU78S99ICqeUKGi9Vvsd8i4y/u2FASVhFBEOBLx5vqhbIJhNOCbr98KsO9+4yZ1TpfulM6xXpCILvpf6PpAoGBAOFgPh7GadrtI9y9YJ+O2w7ovqwtNcOYFZjbW67VNUgELim4fFxilG/y7YoDXYQEsH5QHjsxtzHqsK9gdwhwesiKFAQUuI2j4Vsr/W7AqewI/L3AkxmjTIyXAL4ZVP5NcT345k/kCK1RQFRXADlpV4EIzBrIHYyAESksnDZOuNVRAoGBAOAFI+GVig8KLr2AoTn8Wcc1SbC8CMfHnTx60crLyw9eSZZ+xKs12frC/b1cPsbNnPj+lVNdL+oAStfBsaMDd3Xs8ULQPzrHYKpeY4EUApDUBoiWFcnxxqPkoCZWNqToMMp3L46gmUDojFCJAO8qF9wUebrKzifNueK9RFFIRSpG";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ" +
            "8AMIIBCgKCAQEAtZQ1jBkZ4vXzgS3iWkYT6cOBw9CESQ3/RZQKx5YCt2DpXsC6K" +
            "3wV/EOq4ayBtYKDe/DDiSIbcghAp5IeYj8HI5gQUhQAJ44M6L1DxcQH2ju9zN9P" +
            "/EqwnosZRSNJdNCc/5pS9YkVdXr6oS1EuFGe8XYWssuqTafCViMJ6rBBL+" +
            "5BOXh9T/NhgmCAljCAq+MQva9S+KeYnIw4y7UKZ5/Iwk1Iii5uPio3/EdoQf0Xn" +
            "tbsGhiucrMAujXFsXJTmaSBvKlCp4z/CDAyA+VxvVV1Qx/a5eGHTI2tyuZPLOp" +
            "vEcwcF1BWXVG0ucDJAV/KTokub5W6/uI6niZ9dQ2FZb/wmQIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，假设这里的公网IP和端口为：49.269.31.237:8081
    public static String notify_url = " http://localhost:8080/pay/synnotify";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，假设这里的公网IP和端口为：49.269.31.237:8081
    public static String return_url = "http://localhost:8080/pay/return_notify";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
    //public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";

    // 支付宝网关
    public static String log_path = "C:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}